var Random = Mock.Random

// 获取验证码
Mock.mock(/\/captcha/, 'get', function (params) {
  return {
    'captcha': Mock.Random.dataImage('120x40', Mock.mock({'regexp': /\w{4}/}).regexp)
  }
})
// 传入
// {"msg":"success","code":0,"expire":43200,"token":"8afd78d8b436de75990e1b80b4ae3a06"}
//登录
Mock.mock(/\/sys\/login/,'post',function(params){
  return {
    "code": 0,
    "expire": 3600,
    "message": 'success',
    "token": Mock.Random.guid(),
    "role": 'agency'
  }
})
//登出
Mock.mock(/\/sys\/logout/,'get',function(params){
  return {
    "code": 0,
    "result":{
      message: 'success'
    }
  }
})
// 获取种类 /miniapp/type
Mock.mock(/\/miniapp\/type/,'get',function(params){
  return {
    "code": 0,
    "items": [
      {
        "value":1,
        "text":"智慧餐饮"
      },
      {
        "value":2,
        "text":"智慧门店"
      },
      {
        "value":3,
        "text":"智慧微站"
      },
      {
        "value":4,
        "text":"智慧商城"
      }
    ]
  }
})
//获取创建种类详情/miniapp/kindinfos
Mock.mock(/\/miniapp\/kindinfos/,'post',function(params){
  var List=[],i=0,
    kindArr=["智慧餐饮","智慧门店","智慧微站","智慧商城"],
    subjectArr=["企业（含个体工商户）","企业（个体工商户）","企业（含个体工商户）","企业（含个体工商户）"],
    sceneArr=["本地商户个性化经营，提升服务效率","展示商品服务、提升品牌宣传","本地商户个性化经营，提升服务效率","在线交易，营销裂变"],
    professionArr=["外卖、店内点餐、预约点餐、生活服务等","企业官网、婚纱、汽车、房产、自媒体等","外卖、店内点餐、预约点餐、生活服务等","企业官网、婚纱、汽车、房产、自媒体等"];
  for( ;i<5;i++){
    List.push( Mock.mock({
      'id': i,
      'name': kindArr[i],
      'subject': subjectArr[i],
      'scene': sceneArr[i],
      'profession': professionArr[i]
    }) )
  }

  return {
    'code': 0,
    'result': {
      length: 5,
      items: List
    }
  }
})

//获取AppList /miniapp/list
Mock.mock(/\/miniapp\/list/,'get',function(params){
  var List=[],i=0,
    descArr=["智慧微站"],
    typeArr=["shop-mall"]
    versionArr=["企业版","个人版"],
    statusArr=["试用中/未发布","已交费/未发布","已交费/已发布"];
  for( ;i<5;i++){
    List.push( Mock.mock({
      'id': i,
      'name': Random.paragraph(1, 3),
      'desc|1': descArr,
      'miniProduct_code|1': typeArr,
      'version|1': versionArr,
      'status|1': statusArr,
      'limit': Random.date('yyyy-MM-dd')
    }) )
  }

  return {
    'code': 0,
    'page': {
      length: 5,
      content: List
    }
  }
})

// 获取代理后台账户的小程序列表 //applist
// : 400,
// items: []
Mock.mock(/\/agency\/applist/,'post',function(params){
  var List=[],i=0,
    kindArr=["智慧餐饮","智慧门店","智慧微站"],
    versionArr=["企业版","个人版"],
    statusArr=["试用中/未发布","已交费/未发布","已交费/已发布"];
  for( ;i<20;i++){
    List.push( Mock.mock({
      'uniacid': i,
      'name': '小程序名称'+i,
      'manage': '13338336975',
      'type|1': kindArr,
      'consume': 0.00,
      'limit': Random.date('yyyy-MM-dd'),
      'remaining': 14
    }) )
  }

  return {
    'code': 0,
    'result': {
      total: 50,
      list: List
    }
  }
})

// 获取用户的晓琛许详细信息
Mock.mock(/\/miniapp\/userAppDetail/,'post',function(params){
  var List=[],i=0,
    kindArr=["智慧餐饮","智慧门店","智慧微站"],
    versionArr=["企业版","个人版"],
    statusArr=["试用中/未发布","已交费/未发布","已交费/已发布"];
  for( ;i<20;i++){
    List.push( Mock.mock({
      'uniacid': i,
      'name': '小程序名称'+i,
      'manage': '13338336975',
      'type|1': kindArr,
      'consume': 0.00,
      'limit': Random.date('yyyy-MM-dd'),
      'remaining': 14
    }) )
  }
  return {
    'code': 0,
    'result': {
      'appid': Random.integer(),
      'homecode': 'homecode?????',
      'copyright|1': [0,1],
      'remark': Random.paragraph(1, 3)
    }
  }
})

// 获取文章列表miniapp/article/list
Mock.mock(/\/miniapp\/article\/list/,'post',function(params){
  var List=[],i=0,
    kindArr=["智慧餐饮","智慧门店","智慧微站"],
    versionArr=["企业版","个人版"],
    statusArr=["试用中/未发布","已交费/未发布","已交费/已发布"];
  for( ;i<10;i++){
    List.push( Mock.mock({
      'articleId': i,
      'sort': i,
      'type': '智慧微站',
      'title': "文章标题",
      'view': 112,
      'time': Random.date('yyyy-MM-dd'),
      'show|1': [false,true],
      'remaining': 14
    }) )
  }
  return {
    'code': 0,
    'result': {
      total: 50,
      list: List
    }
  }
})
